package ThreadPool.lagou.concurrent.demo06;

/**
 * @author oyz
 * @version 1.1.0
 * @description: 演示多线程操作同一共享变量会出现的原子性问题 造成该操作的原因是由于主存跟cpu内容不一致
 * @date 2022-9-27 14:34
 */
public class Data {

    private float number;

    public void modify(float difference){
        float value = this.number;
        System.out.println(Thread.currentThread().getName()+ " before -"+ value);
        this.number = value + difference;
        System.out.println(Thread.currentThread().getName()+ " -after"+ number);
    }
}
